package com.dy.daemonThread;

public class DeamonThread {
    public static void main(String[] args) {
        Thread thread = new Thread(new ThreadDeamon());
        System.err.println("main开始");
        thread.setDaemon(true);
        thread.start();
        try {
            Thread.sleep(100);
        } catch (InterruptedException e) {
            e.printStackTrace();
            System.err.println("main线程中断");
        }
        System.err.println("main线程结束");

    }
}
class ThreadDeamon implements Runnable{

    @Override
    public void run() {
        while (true){
            System.err.println("守护线程测试");
            try {
                Thread.sleep(10);
            } catch (InterruptedException e) {
                e.printStackTrace();
                System.out.println("线程中断");
            }
        }
    }
}
